package com.tms.vehiclemanagement.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.tms.vehiclemanagement.domain.Vehiclemanagement;
import com.tms.vehiclemanagement.service.IVehiclemanagementService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 车辆管理Controller
 *
 * @author ruoyi
 * @date 2024-11-05
 */
@RestController
@RequestMapping("/vehiclemanagement")
public class VehiclemanagementController extends BaseController
{
    @Autowired
    private IVehiclemanagementService vehiclemanagementService;

    /**
     * 查询车辆管理列表
     */
    @RequiresPermissions("vehiclemanagement:vehiclemanagement:list")
    @GetMapping("/list")
    public TableDataInfo list(Vehiclemanagement vehiclemanagement)
    {
        startPage();
        List<Vehiclemanagement> list = vehiclemanagementService.selectVehiclemanagementList(vehiclemanagement);
        return getDataTable(list);
    }

    /**
     * 导出车辆管理列表
     */
    @RequiresPermissions("vehiclemanagement:vehiclemanagement:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, Vehiclemanagement vehiclemanagement)
    {
        List<Vehiclemanagement> list = vehiclemanagementService.selectVehiclemanagementList(vehiclemanagement);
        ExcelUtil<Vehiclemanagement> util = new ExcelUtil<Vehiclemanagement>(Vehiclemanagement.class);
        util.exportExcel(response, list, "车辆管理数据");
    }

    /**
     * 获取车辆管理详细信息
     */
    @RequiresPermissions("vehiclemanagement:vehiclemanagement:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(vehiclemanagementService.selectVehiclemanagementById(id));
    }

    /**
     * 新增车辆管理
     */
    @RequiresPermissions("vehiclemanagement:vehiclemanagement:add")
    @PostMapping
    public AjaxResult add(@RequestBody Vehiclemanagement vehiclemanagement)
    {
        vehiclemanagement.setStatus(1);
        return toAjax(vehiclemanagementService.insertVehiclemanagement(vehiclemanagement));
    }

    /**
     * 修改车辆管理
     */
    @RequiresPermissions("vehiclemanagement:vehiclemanagement:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody Vehiclemanagement vehiclemanagement)
    {
        return toAjax(vehiclemanagementService.updateVehiclemanagement(vehiclemanagement));
    }

    /**
     * 删除车辆管理
     */
    @RequiresPermissions("vehiclemanagement:vehiclemanagement:remove")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(vehiclemanagementService.deleteVehiclemanagementByIds(ids));
    }
}
